package com.gla;

import com.gla.interceptor.AuthInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class InterceptorConfig extends WebMvcConfigurationSupport {
    @Override
    public void addInterceptors(InterceptorRegistry reg) {
        reg.addInterceptor(new AuthInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns(excludePattern());//排除
    }

    //没登录可以访问的接口
    public List<String> excludePattern(){
        List<String> ret = new ArrayList<String>();
        ret.add("/login/login");//登录请求
        ret.add("/login/register");
        ret.add("/shop/getAllShop");
        ret.add("/shop/getOneShop");
        ret.add("/shop/getCommodityByShopIdAndPOU");
        ret.add("/shop/getCommodityById");
        ret.add("/shop/getAllCommodityByPOU");
        ret.add("/shop/getAllEvaluationByCMId");
        ret.add("/shop/getVedioByCMId");
        ret.add("/shop/getVedioByType");
        ret.add("/shop/getOneVedio");
        ret.add("/shop/getOneCarByCMIdAndUId");
        ret.add("/getVedioByType");
        ret.add("/checkName");
        ret.add("/Search/getNearShop");
        ret.add("/Search/getSearchShop");
        ret.add("/Search/getSearchPet");
        ret.add("/Search/getSearchPetGoods");
        ret.add("/Video/videoAllShop");
        ret.add("/Video/getPet");
        ret.add("/Video/getPetGoods");
        ret.add("/shop/getEvaBySPId");
        ret.add("/Search/getSearchFine");
        ret.add("/demo/mq");
        ret.add("/shop/getShopNear");

        return ret;
    }
}